package cn.hx.mall_goods.controller;
import cn.hx.mall_goods.CounterDemo;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;


@Component
@Aspect
public class AopTest {
    CounterDemo counterDemo = new CounterDemo();
    @Around("execution(* cn.hx.mall_goods.controller.*.*(..))")
    public Object aop3(ProceedingJoinPoint point) throws Throwable {
        System.out.println("进入控制层");
        boolean grant = counterDemo.grant();
        if (grant) {
            return point.proceed();
        } else {
            throw new RuntimeException("访问次数过多，请稍后再试");
        }
    }
}